﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Enterprise.Model.Vote;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
namespace Enterprise.Data.Vote
{
    /// <summary>
    /// 投票
    /// </summary>
    public class VoteData
    {
        /// <summary>
        ///  数据列表
        /// </summary>
        /// <returns></returns>
        public List<VoteEntity> VoteList()
        {
            List<VoteEntity> list = new List<VoteEntity>();
            string cmd = "Select * from VOTE_INFO";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                VoteEntity entity = new VoteEntity();
                if (!Convert.IsDBNull(dr["VID"])) entity.VID = Convert.ToString(dr["VID"]);
                if (!Convert.IsDBNull(dr["VTITLE"])) entity.VTITLE = Convert.ToString(dr["VTITLE"]);
                if (!Convert.IsDBNull(dr["VTYPE"])) entity.VTYPE = Convert.ToInt32(dr["VTYPE"]);
                if (!Convert.IsDBNull(dr["VENDTIME"])) entity.VENDTIME = Convert.ToDateTime(dr["VENDTIME"]);
                if (!Convert.IsDBNull(dr["VRANGE"])) entity.VRANGE = Convert.ToString(dr["VRANGE"]);
                if (!Convert.IsDBNull(dr["VREMARK"])) entity.VREMARK = Convert.ToString(dr["VREMARK"]);
                if (!Convert.IsDBNull(dr["VCREATEUSER"])) entity.VCREATEUSER = Convert.ToInt32(dr["VCREATEUSER"]);
                if (!Convert.IsDBNull(dr["VCREATETIME"])) entity.VCREATETIME = Convert.ToDateTime(dr["VCREATETIME"]);
                if (!Convert.IsDBNull(dr["VMIX"])) entity.VMIX = Convert.ToInt32(dr["VMIX"]);
                if (!Convert.IsDBNull(dr["VMAX"])) entity.VMAX = Convert.ToInt32(dr["VMAX"]);
                if (!Convert.IsDBNull(dr["VPUBLIC"])) entity.VPUBLIC = Convert.ToInt32(dr["VPUBLIC"]);
                if (!Convert.IsDBNull(dr["VPUBLICTIME"])) entity.VPUBLICTIME = Convert.ToDateTime(dr["VPUBLICTIME"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void Execute(string cmd)
        {
            DbExecute.Execute(cmd);
        }
    }
}
